import React from 'react';

import { Select, Icon, Divider } from 'antd';



const { Option } = Select;

function DutySelect(props) {
  const {dataArr,operateItemType,operateItem}=  props.data

    return (
      <Select
        style={{ width: 240 }}
        value={dataArr.length>0?dataArr[0].name:""}
        dropdownRender={menu => (
          <div>
                 <div
                    style={{ padding: '4px 8px', cursor: 'pointer' }}
                    onMouseDown={e => e.preventDefault()}
                    onClick={operateItem}
                  >
                      {operateItemType=="addItem"?
                        <div>
                        <Icon type="plus" /> 加入
                        </div>
                        : 
                        <div>
                        <Icon type="minus" /> 退出
                        </div>
                     }
                  </div>
                    <Divider style={{ margin: '4px 0' }} />
                    {menu}
                </div>
        )}
      >
        {dataArr.map(item => (
          <Option key={item.id}>{item.name}</Option>
        ))}
      </Select>
    );
}


export  default  DutySelect;